<template>
  <div class="resumedata">
    <el-row>
      <el-col :span="24">
        <el-table :data="companyList" border highlight-current-row fit @row-dblclick="openPreview">
          <el-table-column prop="resume_name" label="简历名称" align="center"></el-table-column>
          <el-table-column prop="job_title" label="应聘职位" align="center"></el-table-column>
          <el-table-column prop="school_info" label="毕业院校" align="center"></el-table-column>
          <el-table-column prop="end_education" :formatter="formatterEducation" label="最高学历"
                           align="center"></el-table-column>
          <el-table-column prop="create_time" label="投递时间" align="center" width="180"></el-table-column>
          <el-table-column prop="status" label="状态" align="center"></el-table-column>
          <el-table-column label="操作" align="center" width="150">
            <template slot-scope="scope">
              <el-tooltip class="item" effect="light" content="接收" placement="top">
                <i class="fa fa-check-circle icon-style" aria-hidden="true" @click="companyResumeAccept(scope.row)"></i>
              </el-tooltip>
              <el-tooltip class="item" effect="light" content="拒绝" placement="top">
                <i class="fa fa-times icon-style" @click="companyResumeRefuse(scope.row)"></i>
              </el-tooltip>
              <el-tooltip class="item" effect="light" content="查看" placement="top">
                <i class="fa fa-eye icon-style" aria-hidden="true" @click="view(scope.row)"></i>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination @current-change="handleCurrentChange" layout="total, prev, pager, next" :total="total"
                       class="table-page-style"></el-pagination>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import { postDataToServer } from '../../assets/js/post.js'
  import { commonNotify } from '../../assets/js/common.js'
  import { getStaticMapList } from '../../assets/js/GlobeDefine.js'
  import { getToolBarList } from '../../assets/js/buildStructure/list.js'
  import ListToolBar from '../common/ListToolbar'

  export default {
    name: 'resumedata',
    props: ['status'],
    data () {
      return {
        authority: 15,
        companyList: [],
        total: 0,
        page_no: 1,
        company: [],
        mes: '',
        mess: '',
        value1: '3',
        value2: '4',
        newstatus: ''
      }
    },
    methods: {
      //接受
      companyResumeAccept (row) {
        let _this = this
        let params = new Object()
        params.id = row.id
        params.status = _this.value1
        postDataToServer('HM_RESUME_DELIVERY_COMPANY_EDIT', params).then((data) => {
          if (data.status === 0) {
            this.$message({
              showClose: true,
              message: '操作成功！'
            })
            this.getcompanyList()
          } else {
            this.$message({
              showClose: true,
              message: data.message
            })
          }
        })
      },
      //拒绝
      companyResumeRefuse (row) {
        let _this = this
        let params = new Object()
        params.id = row.id
        params.status = _this.value2
        postDataToServer('HM_RESUME_DELIVERY_COMPANY_EDIT', params).then((data) => {
          if (data.status === 0) {
            this.$message({
              showClose: true,
              message: '操作成功！'
            })
            this.getcompanyList()
          } else {
            this.$message({
              showClose: true,
              message: data.message
            })
          }
        })
      },
      //查看
      view (row) {
        this.$router.push({'path': '/companyinboxdetail/' + row.id + '/' + row.resume_id})
      },
      //双击表格内容
      openPreview (row, event) {
        if (row.status === '未查看') {
          let _this = this
          let params = new Object()
          params.status = 2
          params.id = row.id
          postDataToServer('HM_RESUME_DELIVERY_COMPANY_EDIT', params).then((data) => {
            if (data.status === 0) {
              _this.getcompanyList()
            }
          })
        }
        this.$router.push({'path': '/companyinboxdetail/' + row.id + '/' + row.resume_id})
      },
      handleCurrentChange (pageNum) {
        this.page_no = pageNum
      },
      getcompanydata () {
        let _this = this
        let param = new Object()
        postDataToServer('ACCOUT_BASEINFO', param).then((data) => {
          if (data.status === 0) {
            _this.company = data.companyinfo
            _this.getcompanyList()
          }
        })
      },
      getcompanyList () {
        let _this = this
        let params = new Object()
        params.page_no = _this.page_no
        params.page_size = 20
        params.company_id = _this.company.id
        if (_this.status !== 0) {
          params.status = _this.status
        }
        postDataToServer('HM_RESUME_DELIVERY_COMPANY_LISTPAGE', params).then((data) => {
          _this.companyList = data.data_list
          _this.total = data.total_results
          if (data.status === 0) {
            let i = 0
            for (i = 0; i < _this.companyList.length; i++) {
              if (_this.companyList[i].status === 1) {
                _this.mess = '未查看'
                _this.companyList[i].status = _this.mess
              } else if (_this.companyList[i].status === 2) {
                _this.mess = '已查看'
                _this.companyList[i].status = _this.mess
              } else if (_this.companyList[i].status === 3) {
                _this.mess = '感兴趣'
                _this.companyList[i].status = _this.mess
              } else if (_this.companyList[i].status === 4) {
                _this.mess = '不合适'
                _this.companyList[i].status = _this.mess
              }
            }
          }
        }).catch((error) => {
          commonNotify(_this, 1, 'GET')
        })
      },
      formatterEducation (row, column) {
        return getStaticMapList('education', row.end_education)
      },
    },
    created () {
      this.getcompanydata()
    },
    watch: {
      page_no: function (val, oldVal) {
        this.getcompanyList(val)
      },
    }
  }
</script>
<style scoped>
  .icon-style {
    font-size: 20px;
    color: #20a0ff;
    margin: 5px;
    cursor: pointer;
  }
</style>
